<!DOCTYPE HTML>
<html>
	<head>
		<?php

	  if (isset($title)) {
	      $this->assign('title', $title);
	  }

		//echo $this->Html->css('cake.generic');
		echo $this->Html->css('bootstrap');
		echo $this->Html->css('style');
		echo $this->Html->css('etalage');
		echo $this->Html->css('owl.carousel');

		echo $this->Html->script('jquery.min');
		echo $this->Html->script('jquery.etalage.min');
		echo $this->Html->script('owl.carousel');
		echo $this->Html->script('maskedinput.min');

		echo $this->fetch('meta');
		echo $this->fetch('css');
		echo $this->fetch('script');

		?>
		<title><?php echo $this->fetch('title'); ?> | Cherrie</title>
   		 <!-- Custom Theme files -->
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<link rel="shortcut icon" href="<?php echo $this->Html->webroot('img/icone.png') ?>">
		<!-- webfonts -->
		<link href='http://fonts.googleapis.com/css?family=Glegoo:400,700' rel='stylesheet' type='text/css'>
		<link href='http://fonts.googleapis.com/css?family=Rochester' rel='stylesheet' type='text/css'>
		<link href='http://fonts.googleapis.com/css?family=Lora:400,700' rel='stylesheet' type='text/css'>
		<!-- webfonts -->
	</head>
	<body>
		<!-- container -->
		<!-- header -->
		<div class="header">
			<!-- top-header -->
			<div class="top-header">
				<div class="container">
					<?php $user = $this->Session->read('Auth.User'); ?>
					<?php if(isset($user)): ?>
					<p class="usuario">Olá, <?php echo $user['nome'] ?> |
						<?php echo $this->Html->link('Sair', array('controller'=>'users','action'=>'logout')) ?>
					</p>
					<?php endif; ?>
					<div class="rigister-info">

		          <?php if(isset($user)): ?>
								<?php if($user['role'] === 'admin'): ?>
									<?php echo $this->Html->link('Painel de Controle', array('admin' => true, 'controller'=>'users','action'=>'index'), array('class' => 'linkHome')) ?>
								<?php else: ?>
									<?php echo $this->Html->link('Minha Conta', array('controller'=>'users','action'=>'index'), array('class' => 'linkHome')) ?>
								<?php endif ?>
								<?php echo " | "?>
								<?php echo $this->Html->link('Meu Carrinho', array('controller'=>'produtos','action'=>'ver_carrinho'), array('class' => 'linkHome')) ?>
		          <?php else: ?>
								<?php echo $this->Html->link('Entrar', array('controller'=>'users','action'=>'login'), array('class' => 'linkHome')) ?>
								<?php echo " | "?>
								<?php echo $this->Html->link('Cadastre-se', array('controller'=>'users','action'=>'add'), array('class' => 'linkHome')) ?>
		          <?php endif; ?>
							<div class="clearfix"> </div>

					</div>
					<div class="clearfix"> </div>
				</div>
			</div>
			<!-- /top-header -->
			<!-- bottom-header -->
			<div class="bottom-header">
				<div class="container">
					<div class="bottom-header-left"></div>
					<div class="logo">
						<a href="/"><?php echo $this->Html->image("logo.png", array("title"=>"cherrie")); ?></a>
					</div>
					<div class="bottom-header-right">
						<div id="social-icons" style="text-align:center;">
						<a href="mailto:contato.cherrie@outlook.com"><?php echo $this->Html->image("email.png", array("width"=>"48", "height"=>"48", "alt"=>"E-mail")) ?></a>
							<a href="http://www.facebook.com/cherriesp" target="_blank"><?php echo $this->Html->image("facebook-pink-flambe.png", array("width"=>"48", "height"=>"48", "alt"=>"Facebook")) ?></a>
							<a href="http://instagram.com/cherrie_sp/" target="_blank"><?php echo $this->Html->image("instagram.png", array("width"=>"48", "height"=>"48", "alt"=>"Instagram")) ?></a>
						</div>
					</div>
				</div>
			</div>
			<!-- /bottom-header -->
		</div>
		<!-- header -->
		<!--- top-nav -->
		<div class="top-nav">
			<div class="main-menu">
				<span class="menu"> </span>
		        <ul>
		        <li><?php echo $this->Html->link('Home', '/')?></li>
		        <?php foreach($menu as $link): ?>
							<?php $isDropdown = (count($link['Tipo']) > 0); ?>
		          <li class="<?php echo ($isDropdown) ? 'dropdown' : '' ?>"><?php echo $this->Html->link($link['Categoria']['nome'], array('controller' => 'produtos', 'action' => 'listar', 'categoria' => $link['Categoria']['id']))?>
		          <?php if($isDropdown): ?>
		            <ul>
		                <?php foreach($link['Tipo'] as $tipo): ?>
											<?php if($tipo['ativo']): ?>
		                  <li>
		                    <?php echo $this->Html->link($tipo['nome'], array('controller' => 'produtos', 'action' => 'listar', 'tipo' => $tipo['id']))?>
		                  </li>
											<?php endif ?>
		                <?php endforeach; ?>
		            </ul>
		          <?php endif; ?>
		          </li>
		        <?php endforeach; ?>
					<li style="float:right">
						<div class="search-box">
							<?php echo $this->Form->create('Produto', array('action' => 'buscar')); ?>
			        		<?php echo $this->Form->input('busca', array('type' => 'text', 'label' => false, 'placeholder' => 'Buscar', 'id' => 'search', 'div'=>false)); ?>
			        		<?php echo $this->Form->submit('', array('div' => false));?>
			        		<?php echo $this->Form->end(); ?>
						</div>
					</li><div class="clearfix"> </div>
		        </ul>
		    </div>
		</div>
		<!--- top-nav -->
		<!-- script-for-nav -->
		<script>
			$(document).ready(function(){
				$("span.menu").click(function(){
					$(".top-nav ul").slideToggle(500);
				});
			});
		</script>
		<!-- top-grids -->
		<!-- bottom-grids -->
		<div class="bottom-grids">
			<div class="container">
				<?php echo $this->Session->flash(); ?>
	      <?php echo $this->fetch('content'); ?>
			</div>
			<?php //echo $this->element('sql_dump'); ?>
		</div>
		<!-- bottom-grids -->
		<!-- footer -->
		<div class="footer">
			<div class="container">
				<div class="footer-grids">
					<div class="col-md-2 footer-grid">
						<h3>Informação</h3>
						<ul>
							<li>
								<?php echo $this->Html->link('Sobre Nós', array('controller' => 'pages', 'action' => 'empresa')) ?>
							</li>
						</ul>
					</div>
					<div class="col-md-2 footer-grid">
						<h3>Mapa do Site</h3>
						<ul>
 							<?php foreach($menu as $link): ?>
 								<li><?php echo $this->Html->link($link['Categoria']['nome'], array('controller' => 'produtos', 'action' => 'listar', 'categoria' => $link['Categoria']['id']))?></li>
 							<?php endforeach; ?>
						</ul>
					</div>
					<div class="col-md-2 footer-grid">
						<h3>Fale Conosco</h3>
						<ul>
							<li>
								<?php echo $this->Html->link('Contato', array('controller' => 'pages', 'action' => 'contato')) ?>
							</li>
							<li>
								<?php echo $this->Html->link('Sobre Trocas', array('controller' => 'pages', 'action' => 'sobre_trocas')) ?>
							</li>
						</ul>
					</div>
					<div class="col-md-3 footer-grid">
						<?php echo $this->Html->image('logo_dan_campos.png', array('class' => 'logo'));?>
					</div>
					<div class="clearfix"> </div>
				</div>
				<!-- social-icons -->
				<div class="social-icons text-center">
					<!-- INICIO CODIGO PAGSEGURO -->
					<center>
					<img class="pagseguro" src='https://p.simg.uol.com.br/out/pagseguro/i/banners/pagamento/todos_animado_550_50.gif' alt = 'Logotipos de meios de pagamento do PagSeguro' title = 'Este site aceita pagamentos com Visa, MasterCard, Diners, American Express, Hipercard, Aura, Elo, PLENOCard, PersonalCard, BrasilCard, FORTBRASIL, Cabal, Mais!, Avista, Grandcard, Sorocred, Bradesco, Itaú, Banco do Brasil, Banrisul, Banco HSBC, saldo em conta PagSeguro e boleto.' />
					</center>
					<!-- FINAL CODIGO PAGSEGURO -->
				</div>
				<!-- social-icons -->
				<!-- footer-bottom -->
				<div class="footer-bottom">
					<div class="footer-bottom-left">
						<p>Copyright Cherrie &#169; 2015 Todos os direitos Reservados | Todo conteúdo do site é de propriedade exclusiva da Cherrie</p>
					</div>
					<div class="clearfix"> </div>
					<!-- footer-bottom -->
				</div>
			</div>
		</div>
		<!-- footer -->
		<!-- container -->
		<script>
		$( document ).ready(function() {
    		jQuery(function($){
			   $(".date").mask("99/99/9999",{placeholder:"dd/mm/aaaa"});
			   $(".ddd").mask("99");
			   $(".address-number").mask("999999999");
			   $(".cpf").mask("999.999.999-99");
			   $(".cep").mask("99999-999");
			});

			$('.phone').keypress(function(){
			   	if($(this).val().length == 9){
			   		$(this).mask("9999-9999");
			   	}else if($(this).val().length == 10){
			   		$(this).mask("99999-9999");
			   	}
			});
		});
		</script>

	</body>
</html>
